<template>
  <router-link v-if="!userStore.isLoggedIn" to="/guest/login/password"  class="btn btn-ghost btn-circle avatar">
    <div class="w-10 rounded-full">
      <img
          alt="用户头像"
          src="/static/images/user_default_180.gif" />
    </div>
  </router-link>
  <div class="dropdown dropdown-end" v-else>
    <div tabindex="0" role="button" class="btn btn-ghost btn-circle avatar">
      <div class="w-10 rounded-full">
        <img
            alt="用户头像"
            :src="userStore.user?.avatar || '/static/images/user_default_180.gif'" />
      </div>
    </div>
    <ul
        tabindex="0"
        class="menu menu-sm dropdown-content bg-base-100 rounded-box z-1 mt-7 w-52 p-2 shadow">
      <li>
        <a class="justify-between">
          Profile
          <span class="badge">New</span>
        </a>
      </li>
      <li><a>设置</a></li>
      <li><a @click="userStore.logout">退出</a></li>
    </ul>
  </div>
</template>
<script>
import { useUserStore } from '@/stores/user'
const userStore = useUserStore()
export default {
  data() {
    userStore.fetchUser()
    return {
      userStore: userStore
    }
  },
  methods:{

  }
}

</script>
   
